package com.shengyin.ec.service.comment;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shengyin.ec.model.dao.comment.CommentDao;
import com.shengyin.ec.model.entity.Comment;

@Service("commentService")
public class CommentServiceImpl implements CommentService{
	@Autowired
	private CommentDao commentDao;
	
	@Override
	public void createComment(Comment comment) {
		commentDao.save(comment);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Comment> findByPage(Long goodsId, int page, int pageSize) {
		if(page<1)
			return null;
		//hql语句
		String hql = "from Comment o where o.goods.id=?";
		//起始记录
		int offset = (page-1)*pageSize;
		return commentDao.findByPage(hql, goodsId, offset, pageSize);
	}

}
